package com.shop.loan.model;

import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.Readonly;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ChoiceType;
import xyz.erupt.annotation.sub_field.sub_edit.DateType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.annotation.sub_field.sub_edit.VL;
import xyz.erupt.jpa.model.BaseModel;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;

@Setter
@Getter
@Erupt(
        name = "支付订单",
        orderBy = "id desc",
        authVerify = false,
//        dataProxy = PayOrderThirdProxy.class,
        power = @Power(add = false, edit = false, delete = false, viewDetails = false)
)
@Table(name = "s_pay_order_third")
@Entity
public class PayOrderThirdByNoAuth extends BaseModel {

//    @Transient
//    @EruptField(
//            edit = @Edit(
//                    title = "手机号码",
//                    show = false,
//                    search = @Search
//            )
//    )
//    private String userPhone;
//
//    @Transient
//    @EruptField(
//            edit = @Edit(
//                    title = "姓名",
//                    show = false,
//                    search = @Search
//            )
//
//    )
//    private String userName;
//
//
//    @Transient
//    @EruptField(
//            views = @View(title = "用户", type = ViewType.SAFE_TEXT, width = LoanOrderUtil.orderListByUserWidth)
//    )
//    private String userInfo;


    @EruptField(
            views = @View(title = "借款订单id"),
            edit = @Edit(title = "借款订单id", search = @Search)
    )
    @Column(name = "order_id")
    private Long orderId;

    @EruptField(
            views = @View(title = "用户id", show = false)
    )
    @Column(name = "user_id")
    private Long userId;

    @EruptField(
            views = @View(title = "类型"),
            edit = @Edit(
                    title = "类型",
                    type = EditType.CHOICE,
                    search = @Search,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "放款", value = "1"),
                                    @VL(label = "还款", value = "2"),
                            }
                    ))
    )
    private Integer type;


    @EruptField(
            views = @View(title = "订单状态"),
            edit = @Edit(
                    title = "订单状态",
                    type = EditType.CHOICE,
                    search = @Search(),
                    notNull = true,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "进行中", value = "1"),
                                    @VL(label = "成功", value = "2"),
                                    @VL(label = "失败", value = "3"),
                            }
                    ))
    )
    private Integer status;

    @EruptField(
            views = @View(title = "还款类型"),
            edit = @Edit(
                    title = "还款类型",
                    type = EditType.CHOICE,
                    notNull = true,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "本息", value = "1"),
                                    @VL(label = "担保费", value = "2"),
                            }
                    ))
    )
    private Integer payType;


    @EruptField(
            views = @View(title = "期数"),
            edit = @Edit(title = "期数")
    )
    private Integer period;

    @EruptField(
            views = @View(title = "金额", width = "120px"),
            edit = @Edit(title = "金额")
    )
    private BigDecimal amount;


    @EruptField(
            edit = @Edit(title = "商户订单号")
    )
    private String outTradeNo;


    @EruptField(
            views = @View(title = "三方交易号"),
            edit = @Edit(title = "三方交易号", search = @Search)
    )
    private String serialNo;


    private String payClient;

    private String payForm;


    @EruptField(
            views = @View(title = "备注"),
            edit = @Edit(title = "备注")
    )
    private String remark;

    @EruptField(
            views = @View(title = "创建时间"),
            edit = @Edit(title = "创建时间",
                    readonly = @Readonly,
                    search = @Search(vague = true),
                    dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    private Date createTime;

    @EruptField(
            views = @View(title = "失败原因"),
            edit = @Edit(title = "失败原因",search = @Search(vague = true))
    )
    private String reason;


    @EruptField(
            views = @View(title = "成功时间"),
            edit = @Edit(title = "成功时间",
                    readonly = @Readonly,
                    search = @Search(vague = true),
                    dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    private Date successTime;

}
